<template>
  <!-- <v-echarts :options="data"/>  -->
  <!-- <ve-line :data="data"></ve-line> -->
  <div class="sales-view">
    <el-card shadow="hover" :body-style="{ padding: '0 0 20px 0' }">
      <template v-slot:header>
        <div class="menu-wrapper">
          <el-menu
            :default-active="activeIndexs"
            mode="horizontal"
            @select="handleSelect"
            class="sales-view-menWu"
          >
            <el-menu-item index="1">销售额</el-menu-item>
            <el-menu-item index="2">访问量</el-menu-item>
          </el-menu>
          <div class="menu-right">
            <el-radio-group v-model="radioSelect" size="small">
              <el-radio-button label="今日" />
              <el-radio-button label="本周" />
              <el-radio-button label="本月" />
              <el-radio-button label="今年" />
            </el-radio-group>
            <el-date-picker
              class="sales-view-data-picker"
              type="daterange"
              v-model="value2"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
              size="small"
            >
            </el-date-picker>
          </div>
        </div>
      </template>
      <template>
        <div class="sales-view-chart-wrapper">
          <v-echarts :options="chartOption" />
          <div class="sales-view-list">
            <div class="sales-view-title">排行榜</div>
            <div class="list-item-weapper">
              <div class="sales-item" v-for="item in rankData" :key="item.no">
                <div :class="['sales-item-no', +item.no <= 3 ? 'top-no' : '']">
                  {{ item.no }}
                </div>
                <div class="sales-item-name">{{ item.name }}</div>
                <div class="sales-item-money">{{ item.money }}</div>
              </div>
            </div>
          </div>
        </div>
      </template>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeIndexs: "1",
      radioSelect: "今日",
      value2: "",
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      chartOption: {
        title: {
          text: "年度销售额",
          textStyle: {
            fontSize: 12,
            color: "#666",
          },
          left: 20,
          top: 25,
        },
        xAxis: {
          type: "category",
          data: [
            "1月",
            "2月",
            "3月",
            "4月",
            "5月",
            "6月",
            "7月",
            "8月",
            "9月",
            "10月",
            "11月",
            "12月",
          ],
          axisTick: {
            // show: false, //刻度隐藏
            alignWithLabel: true, //短竖线与 文字对其
            lineStyle: {
              color: "#999",
            },
          },
          axisLine: {
            lineStyle: {
              color: "#999",
            },
          },
          axisLabel: {
            color: "#333",
          },
        },
        yAxis: {
          axisLine: {
            show: false, //隐藏y轴侧边线条
          },
          axisTick: {
            show: false, //刻度隐藏
          },
          splitLine: {
            lineStyle: {
              type: "dotted", // Y轴改成虚线
              color: "#eee",
            },
          },
        },
        series: [
          {
            type: "bar",
            barWidth: "35%",
            data: [200, 300, 250, 102, 410, 515, 201, 215, 841, 125, 452, 321],
          },
        ],
        color: ["#409eff"],
        grid: {
          top: 70,
          left: 60,
          righ: 60,
          bottom: 50,
        },
      },

      rankData: [
        { no: 1, name: "麦当劳", money: "323.254" },
        { no: 2, name: "麦当劳", money: "323.254" },
        { no: 3, name: "麦当劳", money: "323.254" },
        { no: 4, name: "麦当劳", money: "323.254" },
        { no: 5, name: "麦当劳", money: "323.254" },
      ],
      // data: {
      //   columns: ["日期", "销售额"],
      //   rows: [
      //     { 日期: "1月1日", 销售额: 1223 },
      //     { 日期: "1月2日", 销售额: 1253 },
      //     { 日期: "1月3日", 销售额: 1423 },
      //     { 日期: "1月4日", 销售额: 3123 },
      //     { 日期: "1月5日", 销售额: 2123 },
      //     { 日期: "1月6日", 销售额: 1123 },
      //     { 日期: "1月7日", 销售额: 4123 },
      //   ],
      // },
      // data: {
      //   xAxis: {
      //     type: "category",
      //   },
      //   yAxis: {},
      //   series: [
      //     {
      //       type: "line",
      //       data: [10, 20, 30, 40],
      //     },
      //   ],
      // },
    };
  },
  methods: {
    handleSelect(index) {
      this.activeIndexs = index;
    },
  },
};
</script>
<style lang="scss" scoped>
.sales-view {
  margin-top: 20px;

  .menu-wrapper {
    position: relative;
    display: flex;
    padding-left: 20px;
    // justify-content: space-between;
    // align-items: center;
    .sales-view-menWu {
      width: 100%;
      .el-menu-item {
        height: 50px;
        line-height: 50px;
        margin: 0 20px;
      }
    }
    .menu-right {
      // width: 100%;
      position: absolute;

      top: 0;
      right: 20px;
      height: 50px;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      .sales-view-data-picker {
        margin-left: 20px;
      }
    }
  }
  .sales-view-chart-wrapper {
    display: flex;
    height: 270px;

    .echarts {
      flex: 0 0 70%;
      width: 70%;
      height: 100%;
    }
    .sales-view-list {
      flex: 1;
      width: 100%;
      height: 100%;
      overflow: hidden;

      .sales-view-title {
        margin-top: 20px;
        font-size: 12px;
        color: #666;
        font-weight: 600;
      }
      .list-item-weapper {
        margin-top: 15px;
        .sales-item {
          display: flex;
          align-items: center;
          font-size: 12px;
          padding: 6px 20px 6px 0;
          .sales-item-no {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 20px;
            height: 20px;
            color: #333;
            &.top-no {
              border-radius: 50px;
              background-color: #000;
              color: #fff;
              font-weight: 500;
            }
          }
          .sales-item-name {
            margin-left: 10px;
            color: #333;
          }
          .sales-item-money {
            flex: 1;
            text-align: right;
          }
        }
      }
    }
  }
}
</style>
 